package org.example.core.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.example.core.entity.SupperEntity;
import org.example.core.mysql.KeyAndValuePair;
import org.example.core.mysql.Where;
import org.example.core.repository.BaseRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

public interface BaseDao<I, E extends SupperEntity<I>> {
    List<Map<String, Object>> searchAll(@Param("tableName") String tableName, @Param("keyAndValue") List<KeyAndValuePair> keyAndValuePairList);

    Map<String, Object> getById(@Param("id") I id, @Param("tableName") String tableName, @Param("keyAndValue") List<KeyAndValuePair> fields);

    int update(@Param("id") I id, @Param("tableName") String tableName, @Param("keyAndValue") List<KeyAndValuePair> fields);

    int delete(@Param("id") I id, @Param("tableName") String tableName);

    int add(@Param("tableName") String tableName, @Param("keyAndValue") List<KeyAndValuePair> keyAndValuePairList);

    Map<String, Object> searchOne(@Param("tableName") String tableName, @Param("keyAndValue") List<KeyAndValuePair> fields);

    int count(@Param("tableName") String tableName, @Param("keyAndValue") List<KeyAndValuePair> fields);
}
